#!/usr/bin/ruby -Ku
# -*- coding: utf-8 -*-
require 'test/unit'
require 'm3g'

class Test_CompositingMode < Test::Unit::TestCase
  def setup
  end

  def teadown
  end

  def test_defualt_variables
    cmode = M3G::CompositingMode.new
  
    assert_equal M3G::CompositingMode::REPLACE, cmode.blending
    assert_equal 0   , cmode.alpha_threshold
    assert_equal 0   , cmode.depth_offset.factor
    assert_equal 0   , cmode.depth_offset.units
    assert_equal true, cmode.depth_test_enabled?
    assert_equal true, cmode.depth_write_enabled?
    assert_equal true, cmode.color_write_enabled?
    assert_equal true, cmode.alpha_write_enabled?
  end

  def test_set_variables
    cmode = M3G::CompositingMode.new

    cmode.blending = M3G::CompositingMode::MODULATE
    cmode.alpha_threshold    = 1
    cmode.depth_offset       = [1, 2]
    cmode.depth_test_enable  = false
    cmode.depth_write_enable = false
    cmode.alpha_write_enable = false
    cmode.color_write_enable = false

    assert_equal M3G::CompositingMode::MODULATE, cmode.blending
    assert_equal 1    , cmode.alpha_threshold
    assert_equal 1    , cmode.depth_offset.factor
    assert_equal 2    , cmode.depth_offset.units
    assert_equal false, cmode.depth_test_enabled?
    assert_equal false, cmode.depth_write_enabled?
    assert_equal false, cmode.color_write_enabled?
    assert_equal false, cmode.alpha_write_enabled?
  end

  def test_duplicate
    cmode1 = M3G::CompositingMode.new

    cmode1.blending = M3G::CompositingMode::MODULATE
    cmode1.alpha_threshold    = 1
    cmode1.depth_offset       = [1, 2]
    cmode1.depth_test_enable  = false
    cmode1.depth_write_enable = false
    cmode1.alpha_write_enable = false
    cmode1.color_write_enable = false

    cmode2 = cmode1.duplicate

    assert_equal M3G::CompositingMode::MODULATE, cmode2.blending
    assert_equal 1    , cmode2.alpha_threshold
    assert_equal 1    , cmode2.depth_offset.factor
    assert_equal 2    , cmode2.depth_offset.units
    assert_equal false, cmode2.depth_test_enabled?
    assert_equal false, cmode2.depth_write_enabled?
    assert_equal false, cmode2.color_write_enabled?
    assert_equal false, cmode2.alpha_write_enabled?
  end
end
